package unit_conversion;

/**
 *
 * @author Shimu
 * @date 26-Oct-2013
 */
public class BinaryConversion {
    
    private static final int CONST = 1024;
    
    private static final int CONST2 = CONST * CONST;
    
    private static final int CONST3 = CONST * CONST2;
    
    /**
     * Returns the number of bytes in the given number of kilobytes (KB). 
     * @param kb
     * @return 
     */
    public static long kbToBytes(long kb) {
        return kb * CONST;
    }
    
    /**
     * Returns the number of bytes in the given number of megabytes (MB).
     * @param mb
     * @return 
     */
    public static long mbToBytes(long mb) {
        return kbToBytes(mbToKb(mb));
    }
    
    /**
     * Returns the number of kilobytes (KB) in the given number of 
     * megabytes (MB).
     * @param mb
     * @return 
     */
    public static long mbToKb(long mb) {
        return mb * CONST;
    }
    
    public static long gbToBytes(long gb) {
        return mbToBytes(gbToMb(gb));
    }
    
    public static long gbToKb(long gb) {
        return mbToKb(gbToMb(gb));
    }
    
    public static long gbToMb(long gb) {
        return gb * CONST;
    }
    
    public static double bytesToKb(long bytes) {
        return bytes / (double) CONST;
    }
    
    public static double bytesToMb(long bytes) {
        return bytes / (double) CONST2;
    }
    
    public static double bytesToGb(long bytes) {
        return bytes / (double) CONST3;
    }
    
    public static double kbToMb(long bytes) {
        return bytes / (double) CONST;
    }
    
    
}
